﻿using Sunny.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace PanhuaWin.工厂.仓库.报表
{
    public partial class Form投入产出汇总 : UIPage
    {
        public Form投入产出汇总()
        {
            InitializeComponent();
            uiDataGridView临时.AutoGenerateColumns = false;
        }

        private void uiButton查询_Click(object sender, EventArgs e)
        {
            query();
        }

        private void query()
        {
            string sql = @"SELECT  V3,V1 生产线, sum([投入]) 投入量,sum([产出A1]) A1,sum([产出A2]) A2,sum([产出B]) B,sum([产出S]) S,
sum([产出A1]) + sum([产出A2]) + sum([产出B]) 总产出
                            ,(sum([产出A1]) + sum([产出A2])+sum([产出B]))/ sum([投入])  成材率,(sum([产出B]) / (sum([产出A1]) + sum([产出A2])+sum([产出B])))  B级品率
                            ,sum([产出S])/ sum([投入]) 废品率,sum(汇总面积) 总面积 FROM [View_投入产出汇总2]
                            WHERE 1=1";
            sql += "and [产出日期] >= '" + this.uiDatePicker开始日期.Value + "'";
            sql += "and [产出日期] >= '" + this.uiDatePicker结束日期.Value + "'";
            sql += "group by V1,V3 order by V3";
            DataTable dataTable = pub.GetDataTable(pub.ConnectionString,sql);
            uiDataGridView临时.DataSource = dataTable;
            uiDataGridView临时.Refresh();
        }

        private void Form投入产出汇总_Load(object sender, EventArgs e)
        {
            this.uiDatePicker开始日期.Value = DateTime.Today.AddDays(-1);
            this.uiDatePicker结束日期.Value = DateTime.Today.AddDays(-1);
        }
    }
}
